import cv2
import matplotlib.pyplot as plt
import numpy as np


def show(img):
    cv2.imshow("img", img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()


pie = cv2.imread("./01_Picture/13_Lena.jpg", cv2.IMREAD_GRAYSCALE)
sobelx = cv2.Sobel(pie, cv2.CV_64F, 1, 0, ksize=3)
sobely = cv2.Sobel(pie, cv2.CV_64F, 0, 1, ksize=3)
sobely = cv2.convertScaleAbs(sobely)
sobelx = cv2.convertScaleAbs(sobelx)
sobelxy = cv2.addWeighted(sobelx, 0.5, sobely, 0.5, 0)

scharrx = cv2.Scharr(pie, cv2.CV_64F, 1, 0)
scharry = cv2.Scharr(pie, cv2.CV_64F, 0, 1)
scharry = cv2.convertScaleAbs(scharry)
scharrx = cv2.convertScaleAbs(scharrx)
scharrxy = cv2.addWeighted(scharrx, 0.5, scharry, 0.5, 0)

laplacian = cv2.Laplacian(pie, cv2.CV_64F)
laplacian = cv2.convertScaleAbs(laplacian)

res = np.hstack((sobelxy, scharrxy, laplacian))
show(res)




